<?php
	
	global $flash_changed;
	$flash_changed = false;
	
	function flash($key, $value = null)
	{
		global $flash_changed;
		
		if($value == null)
		{
			if(isset($_SESSION["flash"]["$key"]))
			{
				return $_SESSION["flash"]["$key"];
			}else{
				return false;
			}
		}
		else
		{
			if(! isset($_SESSION['flash']))
			{
				$_SESSION['flash'] = array();
			}
			
			$flash_changed = true;
			$_SESSION["flash"]["$key"] = $value;
		}
	}
	
	function flush_flash()
	{
		global $flash_changed;
		
		if(! $flash_changed)
		{
			if(isset($_SESSION["flash"]))
			{
				unset($_SESSION['flash']);
			}
		}
		
	}